import { defineStore } from 'pinia';

// 智能体管理 Store
export const useAgentStore = defineStore('agent', () => {
  // 当前选中的智能体
  const currentAgent = ref<any>({
    id: '1921838545713623041',
    name: '通用智能体',
    addr: 'http://192.168.1.151:8109/v1/chat-messages',
    keyStr: 'app-a02N9D4HWwnY92Bmem4Sdvs0',
    createDate: '2025-05-12 16:03:10',
  });

  // 设置当前智能体
  const setCurrentAgent = (agent: any) => {
    currentAgent.value = agent;
  };

  // 获取当前智能体的 keyStr
  const getCurrentAgentKey = () => {
    return currentAgent.value?.keyStr; // 默认值
  };

  // 清空当前智能体
  const clearCurrentAgent = () => {
    currentAgent.value = null;
  };

  return {
    currentAgent: readonly(currentAgent),
    setCurrentAgent,
    getCurrentAgentKey,
    clearCurrentAgent,
  };
}, {
  persist: true,
});
